package com.springboot.dense.service.impl;

import com.springboot.dense.dto.FogLevelDTO;
import com.springboot.dense.entity.FogLevel;
import com.springboot.dense.mapper.FogLevelMapper;
import com.springboot.dense.service.FogLevelService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.springboot.dense.vo.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author ${author}
 * @since 2021-04-14
 */
@Service
public class FogLevelServiceImpl extends ServiceImpl<FogLevelMapper, FogLevel> implements FogLevelService {

    @Autowired
    private FogLevelMapper FogLevelMapper;

    @Override
    public List<FogLevelDTO> findByAll() {
        return FogLevelMapper.findByAll();
    }

    @Override
    public List<FogLevelDTO> findByone(int id) {
        return FogLevelMapper.findByone(id);
    }

    @Override
    public List<FogLevelDTO> findsearchAll(String city, String type) {
        if(city.equals("no") && !type.equals("no")){
            return FogLevelMapper.findsearchLevel(Integer.parseInt(type));
        }else if(!city.equals("no") && type.equals("no")){
            return FogLevelMapper.findsearchCity(city);
        }
        return FogLevelMapper.findsearchAll(city,Integer.parseInt(type));
    }

    @Override
    public List<CityAlertVO> findCityAlertByDate(String date) {
        System.out.println(date);
        return FogLevelMapper.findCityAlertByDate(date);
    }

    @Override
    public List<CityHistoryLevelVO> findCityHistoryLevel() {
        return FogLevelMapper.findCityHistoryLevel();
    }

    @Override
    public List<CityLastWeekLevelVO> findCityLastWeekLevel(String city) {
        return FogLevelMapper.findCityLastWeekLevel(city);
    }

    @Override
    public List<CityHistoryDetailVO> findCityLastWeekLevelTwo(String city) {
        return FogLevelMapper.findCityLastWeekLevelTwo(city);
    }

    @Override
    public CityDetailVO findOneCityDetail(String date, String city) {
        return FogLevelMapper.findOneCityDetail(date,city);
    }

}
